﻿layui.define('layer', function (exports) {
    "use strict";
    var $ = layui.jquery,
        layerTips = parent.layer === undefined ? layui.layer : parent.layer;

    var ajax = {
        submit: function (model, url) {
            return $.ajax({
                type: "post",
                url: url,
                cache: false,
                data: JSON.stringify(model),
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            });
        },
        post: function (model, url) {
            return $.ajax({
                type: "post",
                url: url,
                cache: false,
                data: JSON.stringify(model),
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            });
        },
        put: function (model, url) {
            return $.ajax({
                type: "put",
                url: url,
                cache: false,
                data: JSON.stringify(model),
                contentType: "application/json; charset=utf-8",
                dataType: "json"
            });
        },
        delete: function (model, url) {
            return $.ajax({
                type: "delete",
                url: url,
                cache: false,
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(model || {}),
                dataType: "json"
            });
        },
        get: function (url, params) {
            return $.getJSON(url, params);
        },
        v: '1.0.0'
    };

    exports('ajax', ajax);
});